//
//  PTStuLSDemandDetailHeaderCell.m
//  PlanTech
//  需求详情-头部视图
//  Created by ruifeng song on 2018/7/12.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "PTStuLSDemandDetailHeaderCell.h"
#import "XHStarRateView.h"

@interface PTStuLSDemandDetailHeaderCell()

@property(nonatomic,strong)UIImageView * headerImageView;
@property(nonatomic,strong)UILabel *recipientLabel;
@property(nonatomic,strong)XHStarRateView *starRateView;

@end

@implementation PTStuLSDemandDetailHeaderCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _headerImageView =[[UIImageView alloc]initWithFrame:CGRectMake(22,23, 46, 46)];
        _headerImageView.layer.cornerRadius = 23;
        _headerImageView.layer.masksToBounds = YES;
        _headerImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_headerImageView];
        
        _recipientLabel = [[UILabel alloc]initWithFrame:CGRectMake(_headerImageView.right + 15, 30, ScreenWidth - _headerImageView.right - 15 - 15-12 , 18)];
        _recipientLabel.font =PTFONT_BOLD_18;
        _recipientLabel.textColor = PTColor_2e2e2e;
//        _recipientLabel.text=  @"收件人：张嘎嘎";
        [self.contentView addSubview:_recipientLabel];
        
        _starRateView = [[XHStarRateView alloc]initWithFrame:CGRectMake(self.headerImageView.right + 15, _recipientLabel.bottom +6, 58, 10) numberOfStars:5 selectNumberStars:0 rateStyle:WholeStar isAnination:YES isTouch:NO finish:^(CGFloat currentScore) {
            
        }];
        [self.contentView addSubview:_starRateView];
    }
    return self;
}

-(void)updateDemandDetailHeaderCellWith:(LifeServiceListDetailModel *)detailModel
{
    if (detailModel.userAvatar && detailModel.userAvatar.length > 0) {
        
        [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.userAvatar] placeholderImage:[UIImage imageNamed:@"list_header_default_img"]];
    }
    self.recipientLabel.text =[NSString stringWithFormat:@"收件人：%@", detailModel.userName];

    CGFloat starNum = 0;
    
    if (detailModel.userAvgRating !=nil) {
        
        starNum = [detailModel.userAvgRating floatValue];
    }
    
    [self.starRateView setCurrentScore:starNum];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
